import {getUser} from '@/utils/local'
import {isArray} from '@/utils/type'

function getUserAuths(data) {
  const userInfo = getUser()
	console.log(userInfo)
  if (!userInfo) return false
  const {auths} = userInfo
  if (!userInfo) return false
  const isHave = auths.includes(data)

	return isHave
}

export default {
  mounted(el, binding) {
    const {value} = binding
		if (isArray(value)) {
			let ishas = false
			value.forEach(item => {
				if (getUserAuths(item)) {
					ishas = true
				}
			})
			if (!ishas) {
				el.parentNode.removeChild(el)
			}
		} else {
			if (!getUserAuths(value)) {
				el.parentNode.removeChild(el)
			}
		}
  }
}